describe('App.BillPayment', function(){
    var transferObject;
    beforeEach(function(){
        transferObject = App.BillPayment.create();
    });

    it('verify states', function(){
        expect(transferObject.get('isOTPRequired')).toBeTruthy();
        expect(transferObject.get('isPostDateAllowed')).toBeFalsy();
        expect(transferObject.get('isAmountEditable')).toBeFalsy();
    });

    it('transferDataForBillPresentment', function(){
        transferObject.set('payee', Ember.Object.create());
        transferObject.set('payee.payeeId', 'registeredBillerNumber');

        transferObject.set('payee.billerInfo', Ember.Object.create({
            getTransferVOForBillPresentment: function() {
                return {
                    'billerName': 'name',
                    'billerType': 'type',
                    'billerTypeCode': 'typeCode',
                    'billerAccountPin': 'billerAccountPin',
                    'billerValidations': [{field: 'field', fieldLocal:null, value: 'value'}]
                }
            }
        }));

        var data = transferObject.transferDataForBillPresentment();
        expect(data.billerName).toBe('name');
        expect(data.billerType).toBe('type');
        expect(data.billerTypeCode).toBe('typeCode');
        expect(data.billerAccountPin).toBe('billerAccountPin');
        expect(data.regdBillerNumber).toBe('registeredBillerNumber');

        var validations = data.billerValidations;
        expect(validations.length).toBe(1);
        expect(validations[0].field).toBe('field');
        expect(validations[0].value).toBe('value');
    });

    it('transferDataForBillPresentment', function(){
        var expectedObject = {
            transactionRefNo: '1234',
            currencyCode: 'IDR',
            remark: null,
            amount: '10',
            fromAccount: {
                accountNumber: '1111'
            },
            payee: {
                payeeId: '4444'
            }
        };


        transferObject.set('billPresentment', {transactionRefNo: '1234'});
        transferObject.set('currencyCode', expectedObject.currencyCode);
        transferObject.set('remark', expectedObject.remark);
        transferObject.set('amount', expectedObject.amount);
        transferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return {
                    accountNumber: '1111'
                };
            }
        }));
        transferObject.set('payee', Ember.Object.create({
            getTransferVO: function() {
                return {
                    payeeId: '4444'
                };
            }
        }));

        expect(JSON.stringify(transferObject.transferDataForAccept())).toBe(JSON.stringify(expectedObject));
    });
    it('transferDataForGenerateEtac', function(){
        var expectedObject = {
            transactionRefNo: '1234',
            currencyCode: 'IDR',
            remark: null,
            amount: '10',
            fromAccount: {
                accountNumber: '1111'
            },
            payee: {
                payeeId: '4444'
            }
        };


        transferObject.set('billPresentment', {transactionRefNo: '1234'});
        transferObject.set('currencyCode', expectedObject.currencyCode);
        transferObject.set('remark', expectedObject.remark);
        transferObject.set('amount', expectedObject.amount);
        transferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return {
                    accountNumber: '1111'
                };
            }
        }));
        transferObject.set('payee', Ember.Object.create({
            getTransferVO: function() {
                return {
                    payeeId: '4444'
                };
            }
        }));

        expect(JSON.stringify(transferObject.transferDataForGenerateEtac())).toBe(JSON.stringify(expectedObject));
    });
    it('transferDataVO', function(){
        var expectedObject = {
            transactionRefNo: '1234',
            currencyCode: 'IDR',
            remark: null,
            amount: '10',
            fromAccount: {
                accountNumber: '1111'
            },
            payee: {
                payeeId: '4444'
            },
            "etacReqId":"BPYID20130415000066ID01I0211000521"
        };


        transferObject.set('billPresentment', {transactionRefNo: '1234'});
        transferObject.set('currencyCode', expectedObject.currencyCode);
        transferObject.set('remark', expectedObject.remark);
        transferObject.set('amount', expectedObject.amount);
        transferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return {
                    accountNumber: '1111'
                };
            }
        }));
        transferObject.set('payee', Ember.Object.create({
            getTransferVO: function() {
                return {
                    payeeId: '4444'
                };
            }
        }));
        transferObject.set('etacResult', {
            "etacReqId":"BPYID20130415000066ID01I0211000521",
            "etacMobileNo":"919551614141"
        });

        expect(JSON.stringify(transferObject.transferDataVO())).toBe(JSON.stringify(expectedObject));
    });
    it("displayableObjectForEtac",function(){
        transferObject.displayableObjectForEtac();

    });
    it("caution",function(){
       transferObject.caution();
    });
    it("transferDataForOTPResend",function(){
        transferObject.transferDataForOTPResend();
    });

    it("notes-moduleName->preConfirm",function(){
        transferObject.set('moduleName','preConfirm');
        expect(transferObject.get('moduleName')).toBe('preConfirm');

        transferObject.notes();
        transferObject.cautionNotes();
    });

    it("notes-moduleName->confirm",function(){
        transferObject.set('moduleName','confirm');
        expect(transferObject.get('moduleName')).toBe('confirm');

        transferObject.notes();
        transferObject.cautionNotes();
    });


});

describe('validation', function() {
    var transferObject;
    beforeEach(function(){
        transferObject = App.BillPayment.create();
    });

    it('amount less than 1', function() {
        spyOn(BreezeException, 'create');
        try {
            transferObject.validateAmount('0.2');
        } catch(e) {
        }
        expect(BreezeException.create).toHaveBeenCalledWith({errorMessage: App.i18n.getTranslations().get('error.minimumAmountError')});
    });

    it('valid amount', function() {
        spyOn(BreezeException, 'create');
        try {
            transferObject.validateAmount('100.0');
        } catch(e) {
        }
        expect(BreezeException.create).not.toHaveBeenCalled();
    });
});


describe('App.OwnAccountTransfer', function() {
    var transferObject;
    beforeEach(function() {
        transferObject = App.OwnAccountTransfer.create();
    });
    describe('notes', function() {
        it('show notes for confirm screen', function() {
            transferObject.set('moduleName', 'confirm');
            expect(JSON.stringify(transferObject.notes())).toBe(JSON.stringify([
                {
                    key: App.i18n.getTranslations().get('move.noteTitle'),
                    value: App.i18n.getTranslations().get('move.eTACNotes'),
                    isNote: true
                }
            ]));
        });
        it('show notes for pre-confirm screen', function() {
            transferObject.set('moduleName', 'preConfirm');
            expect(JSON.stringify(transferObject.notes())).toBe(JSON.stringify([
                {
                key: App.i18n.getTranslations().get('move.noteTitle'),
                value: App.i18n.getTranslations().get('move.preConfirmOATNotes'),
                isNote: true
                },
                transferObject.cautionNotes()
            ]));
        });
        it('not show notes for other screens', function() {
            transferObject.set('moduleName', '');
            expect(transferObject.notes().length).toBe(0);
        });

        it('show eTAC Resend notes for confirm screen',function(){
            transferObject.set('moduleName', 'confirm');
            var noteText = App.i18n.getTranslations().get('move.eTACNotes');
            transferObject.set('showResendNotes',true);
            expect(transferObject.get('showResendNotes')).toBe(true);
            noteText = App.i18n.getTranslations().get('move.eTACResendNotes') + '\n\n' + noteText;
            expect(JSON.stringify(transferObject.notes())).toBe(JSON.stringify([
                {
                key: App.i18n.getTranslations().get('move.noteTitle'),
                value: noteText,
                isNote: true
                }
            ]));
        });

    });

    describe("exchangeCurrencyCode",function(){
        var expectedObject = {
            "toAccount":{
                "accountNumber": "25728357150",
                "currencyCode": "IDR",
                "productCategory": "CASA"
            },
            "fromAccount":{
                "accountNumber": "25728357148",
                "currencyCode": "IDR",
                "productCategory": "CASA"
            },
            "currencyCode": "IDR"
        };
        beforeEach(function(){
            transferObject.set('currencyCode', expectedObject.currencyCode);

        });
        it("return fromAccount CurrencyCode",function(){
            transferObject.set('fromAccount', Ember.Object.create({
                getTransferProductVO: function() {
                    return expectedObject.fromAccount;
                }
            }));

            transferObject.set('toAccount', Ember.Object.create({
                getTransferProductVO: function() {
                    return expectedObject.toAccount;
                }
            }));
            transferObject.set('toAccount.currencyCode','IDR');
            expect(Ember.none(transferObject.get('toAccount'))).toBe(false);


            transferObject.set('currencyCode','IDR');
            expect(transferObject.get('toAccount').get('currencyCode')).toBe('IDR');
            expect(transferObject.get('exchangeCurrencyCode')).toBe(undefined);
        });

        it("return fromAccount CurrencyCode",function(){
            transferObject.set('fromAccount', Ember.Object.create({
                getTransferProductVO: function() {
                    return expectedObject.fromAccount;
                }
            }));

            transferObject.set('toAccount', Ember.Object.create({
                getTransferProductVO: function() {
                    return expectedObject.toAccount;
                }
            }));
            transferObject.set('fromAccount.currencyCode','IDR');
            expect(Ember.none(transferObject.get('toAccount'))).toBe(false);


            transferObject.set('currencyCode','IDR');
            expect(transferObject.get('fromAccount').get('currencyCode')).toBe('IDR');
            expect(transferObject.get('exchangeCurrencyCode')).toBe(undefined);
        });

        it("return fromAccount if accountCurrency is same as CurrencyCode",function(){
            transferObject.set('fromAccount', Ember.Object.create({
                getTransferProductVO: function() {
                    return expectedObject.fromAccount;
                }
            }));

            transferObject.set('accountCurrency','IDR');
            expect(Ember.none(transferObject.get('toAccount'))).toBe(true);


            transferObject.set('currencyCode','IDR');
            expect(transferObject.get('fromAccount').get('currencyCode')).toBe(undefined);
            expect(transferObject.get('exchangeCurrencyCode')).toBe(undefined);
        });

        it("return fromAccount if accountCurrency is not same as CurrencyCode",function(){
            transferObject.set('accountCurrency','USD');
            expect(Ember.none(transferObject.get('toAccount'))).toBe(true);

            transferObject.set('currencyCode','IDR');
            expect(transferObject.get('accountCurrency')).toBe('USD');
            expect(transferObject.get('exchangeCurrencyCode')).toBe('USD');
        });
    });

    it('transferDataForAccept', function(){
        var expectedObject = {
            "toAccount":{
                "accountNumber": "25728357150",
                "currencyCode": "IDR",
                "productCategory": "CASA"
            },
            "fromAccount":{
                "accountNumber": "25728357148",
                "currencyCode": "IDR",
                "productCategory": "CASA"
            },
            "currencyCode": "IDR",
            "amount": 11.00,
            "remark": "oat"
        };

        transferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return expectedObject.fromAccount;
            }
        }));
        transferObject.set('toAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return expectedObject.toAccount;
            }
        }));
        transferObject.set('currencyCode', expectedObject.currencyCode);
        transferObject.set('amount', expectedObject.amount);
        transferObject.set('remark', expectedObject.remark);
        expect(JSON.stringify(transferObject.transferDataForAccept())).toBe(JSON.stringify(expectedObject));
        expect(JSON.stringify(transferObject.transferDataForGenerateEtac())).toBe(JSON.stringify(expectedObject));
    });

    it("transferCurrencies",function(){
        var expectedObject = {
            "toAccount":{
                "accountNumber": "25728357150",
                "currencyCode": "IDR",
                "productCategory": "CASA"
            },
            "fromAccount":{
                "accountNumber": "25728357148",
                "currencyCode": "IDR",
                "productCategory": "CASA"
            },
            "currencyCode": "IDR"
        };

        transferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return expectedObject.fromAccount;
            }
        }));
        transferObject.set('toAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return expectedObject.toAccount;
            }
        }));
        transferObject.fromAccount.set('currencyCode','IDR');
        transferObject.toAccount.set('currencyCode','IDR');
        var fromCurrency = transferObject.fromAccount.get('currencyCode');
        var toCurrency = transferObject.toAccount.get('currencyCode');
        expect(JSON.stringify(transferObject.transferCurrencies())).toBe(JSON.stringify([{"code":fromCurrency,"value":fromCurrency}]));

    });

    it("showHideResendNotes",function(){
        transferObject.set('showResendNotes',true);
        transferObject.showHideResendNotes(true);
    });

    it("displayableObject--moduleName is confirm",function(){
        var expectedResult = [{"key":"eTAC Reference Number","value":null},{"key":"Mobile Number for eTAC","value":null},{"key":"Notes","value":"I still haven't received my eTAC via SMS. What should I do? \n\nSince eTACs are delivered to you via SMS, it is possible that you may experience some delay in receiving you eTAC due to congestion at your mobile operators network. Once you receive your eTAC, you may return to Breeze and click on the Authorise Transactions link on the left menu. You may then select the transaction by matching the transaction reference number received in the SMS, verify the transaction details and then proceed to enter the eTAC to complete the authorization of the transaction. If you haven't received your eTAC within an hour of performing your transaction, please call our Customer Contact Centre at +62-21-57999988 and 68000 from mobile and we shall help you authorize your transaction.","isNote":true}];
        transferObject.set('moduleName','confirm');
        expect(transferObject.get('moduleName')).toBe('confirm');
        transferObject.displayableObjectForEtac();
        transferObject.notes();
        expect(JSON.stringify(transferObject.get('displayableObject'))).toEqual(JSON.stringify(expectedResult));
    });

//    it("displayableObject--moduleName is other than confirm",function(){
//        transferObject.set('moduleName','preConfirm');
//        expect(transferObject.get('moduleName')).toBe('preConfirm');
//        expect(JSON.stringify(transferObject.get('displayableObject'))).toEqual(JSON.stringify(null));
//    });
});


describe('App.TopUpPayment', function(){
    var transferObject;
    beforeEach(function() {
        transferObject = App.TopUpPayment.create();
    });

    it("transferDataForAccept",function(){
        var expectedObject = {
            'currencyCode':'IDR',
            'remark':'Top up Payment',
            'amount':110.00,
            'fromAccount':{
                "accountNumber": "25728357148",
                "currencyCode": "IDR",
                "productCategory": "CASA"
            },
            'payee':{
                payeeId: '4444'
            }
        };
        transferObject.set('currencyCode',expectedObject.currencyCode);
        transferObject.set('remark',expectedObject.remark);
        transferObject.set('amount',expectedObject.amount);
        transferObject.set('fromAccount',Ember.Object.create({
            getTransferProductVO:function(){
                return expectedObject.fromAccount;
            }
        }));
        transferObject.set('payee',Ember.Object.create({
            getTransferVO:function(){
                return expectedObject.payee;
            }
        }));

        expect(JSON.stringify(transferObject.transferDataForAccept())).toBe(JSON.stringify(expectedObject));

        expect(JSON.stringify(transferObject.transferDataForGenerateEtac())).toBe(JSON.stringify(expectedObject));

    });

    it("transferDataVO",function(){
        var expectedObject = {
            'currencyCode':'IDR',
            'remark':'Top up Payment',
            'amount':110.00,
            'fromAccount':{
                "accountNumber": "25728357148",
                "currencyCode": "IDR",
                "productCategory": "CASA"
            },
            'payee':{
                payeeId: '4444'
            },
            "etacReqId":"BPYID20130415000066ID01I0211000521",
            transactionRefNo: '1234'
        };

        transferObject.set('currencyCode', expectedObject.currencyCode);
        transferObject.set('remark', expectedObject.remark);
        transferObject.set('amount', expectedObject.amount);
        transferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return expectedObject.fromAccount;
            }
        }));
        transferObject.set('payee', Ember.Object.create({
            getTransferVO: function() {
                return expectedObject.payee;
            }
        }));
        transferObject.set('etacResult', {
            "etacReqId":"BPYID20130415000066ID01I0211000521",
            "transactionRefNo":"1234"
            });


        expect(JSON.stringify(transferObject.transferDataVO())).toBe(JSON.stringify(expectedObject));
    });

    it("validateAmount is selected and not empty",function(){
        spyOn(BreezeException, 'create');
        try {
            transferObject.validateAmount('100.0');
        } catch(e) {
        }
        expect(BreezeException.create).not.toHaveBeenCalled();

    });

    it("validateAmount: Amount is not selected and is empty",function(){
        spyOn(BreezeException, 'create');
        try {
            transferObject.validateAmount('');
        } catch(e) {
        }
        expect(BreezeException.create).toHaveBeenCalledWith({errorMessage: App.i18n.getTranslations().get('error.selectionAmountError')});

    });

    it("notes-moduleName->preConfirm",function(){
        transferObject.set('moduleName','preConfirm');
        expect(transferObject.get('moduleName')).toBe('preConfirm');

        transferObject.notes();
        transferObject.cautionNotes();
    });

    it("notes-moduleName->confirm",function(){
        transferObject.set('moduleName','confirm');
        expect(transferObject.get('moduleName')).toBe('confirm');

        transferObject.notes();
        transferObject.cautionNotes();
    });
});

describe("App.OneTimeBillPayment",function(){
    var transferObject;
    var expectedObject;
    beforeEach(function() {
        transferObject = App.OneTimeBillPayment.create();

        expectedObject = {
            "billPresentment": {
                "transactionRefNo": "178290",
                "currencyCode": "IDR",
                "remark": "testing",
                "amount": 215500,
                "fromAccount": {
                    "accountNumber": "25728357148",
                    "currencyCode": "IDR",
                    "productCategory": "CASA"
                },
                "payee": {
                    "biller": {
                        "billerId": 103,
                        "seqNo": 0,
                        "billerName": "Axis",
                        "billerAccountPin": 0,
                        "billerType": "TELECOMMUNICATION",
                        "billerTypeCode": "BILL_PAYMENT",
                        "billerValidations": [{
                            "field": "Mobile Number",
                            "type": "NUMERIC",
                            "required": true,
                            "value": "083123232323",
                            "lengthMax": 30
                        }]
                    }
                }
            }
        };
        transferObject.set('biller',Ember.Object.create({
            getTransferVO:function(){
                return expectedObject.billPresentment.payee.biller;
            }
        }));

    });

    it("transferDataForBillPresentment",function(){
        transferObject.set('biller',Ember.Object.create({
            getTransferVOForBillPresentment:function(){
                return expectedObject.billPresentment.payee.biller;
            }
        }));
       transferObject.transferDataForBillPresentment();
    });

    it("transferDataForAccept",function(){

        transferObject.set('transactionRefNo', expectedObject.billPresentment.transactionRefNo);
        transferObject.set('currencyCode', expectedObject.billPresentment.currencyCode);
        transferObject.set('remark', expectedObject.billPresentment.remark);
        transferObject.set('amount', expectedObject.billPresentment.billAmount);
        transferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return expectedObject.billPresentment.fromAccount;
            }
        }));
        transferObject.set('payee',Ember.Object.create({
            biller:transferObject.biller
        }));
        transferObject.transferDataForAccept();
        transferObject.transferDataForGenerateEtac();
    });

    it("transferDataVO",function(){
        transferObject.set('transactionRefNo', expectedObject.billPresentment.transactionRefNo);
        transferObject.set('currencyCode', expectedObject.billPresentment.currencyCode);
        transferObject.set('remark', expectedObject.billPresentment.remark);
        transferObject.set('amount', expectedObject.billPresentment.billAmount);
        transferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return expectedObject.billPresentment.fromAccount;
            }
        }));
        transferObject.set('payee',Ember.Object.create({
            biller:transferObject.biller
        }));
        transferObject.set('etacResult', {
            "etacReqId":"BPYID20130415000066ID01I0211000521",
            "transactionRefNo":"1234"
        });

        transferObject.transferDataForAccept();
        transferObject.transferDataVO();

    });

    it("displayableObjectForBillerInput",function(){
    });

    it("notes-moduleName->preConfirm",function(){
        transferObject.set('moduleName','preConfirm');
        expect(transferObject.get('moduleName')).toBe('preConfirm');

        transferObject.notes();
        transferObject.cautionNotes();
    });

    it("notes-moduleName->confirm",function(){
        transferObject.set('moduleName','confirm');
        expect(transferObject.get('moduleName')).toBe('confirm');

        transferObject.notes();
        transferObject.cautionNotes();
    });

});

describe("App.OneTimeTopUpPayment",function(){
    var transferObject;
    beforeEach(function(){
       transferObject = App.OneTimeTopUpPayment.create();
    });
    it("validateAmount is selected and not empty",function(){
        spyOn(BreezeException, 'create');
        try {
            transferObject.validateAmount('100.0');
        } catch(e) {
        }
        expect(BreezeException.create).not.toHaveBeenCalled();

    });

    it("validateAmount: Amount is not selected and is empty",function(){
        spyOn(BreezeException, 'create');
        try {
            transferObject.validateAmount('');
        } catch(e) {
        }
        expect(BreezeException.create).toHaveBeenCalledWith({errorMessage: App.i18n.getTranslations().get('error.selectionAmountError')});

    });
    it("transferDataForAccept",function(){
        var expectedObject = {
            currencyCode: 'IDR',
            remark: 'testing',
            amount: '10',
            fromAccount: {
                accountNumber: '1111'
            },
            payee: {
                biller: {
                    billerId:103
                }
            }
        };

        transferObject.set('currencyCode', expectedObject.currencyCode);
        transferObject.set('remark', expectedObject.remark);
        transferObject.set('amount', expectedObject.amount);
        transferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return {
                    accountNumber: '1111'
                };
            }
        }));

        transferObject.set('biller', Ember.Object.create({
            getTransferVO:function(){
                return expectedObject.payee.biller;
            }
        }));

        expect(JSON.stringify(transferObject.transferDataForAccept())).toBe(JSON.stringify(expectedObject));
        expect(JSON.stringify(transferObject.transferDataForGenerateEtac())).toBe(JSON.stringify(expectedObject));
    });

    it("transferDataVO",function(){
        var expectedObject = {
            'currencyCode':'IDR',
            'remark':'One Time Top up Payment',
            'amount':110.00,
            'fromAccount':{
                "accountNumber": "25728357148",
                "currencyCode": "IDR",
                "productCategory": "CASA"
            },
            'payee':{
                biller: {
                    billerId:103
                }
            },
            "etacReqId":"BPYID20130415000066ID01I0211000521",
            transactionRefNo: '1234'
        };

        transferObject.set('currencyCode', expectedObject.currencyCode);
        transferObject.set('remark', expectedObject.remark);
        transferObject.set('amount', expectedObject.amount);
        transferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return expectedObject.fromAccount;
            }
        }));
        transferObject.set('biller', Ember.Object.create({
            getTransferVO: function() {
                return expectedObject.payee.biller;
            }
        }));
        transferObject.set('etacResult', {
            "etacReqId":"BPYID20130415000066ID01I0211000521",
            "transactionRefNo":"1234"
        });


        expect(JSON.stringify(transferObject.transferDataVO())).toBe(JSON.stringify(expectedObject));
    });

    it("notes-moduleName->preConfirm",function(){
        transferObject.set('moduleName','preConfirm');
        expect(transferObject.get('moduleName')).toBe('preConfirm');

        transferObject.notes();
        transferObject.cautionNotes();
    });

    it("notes-moduleName->confirm",function(){
        transferObject.set('moduleName','confirm');
        expect(transferObject.get('moduleName')).toBe('confirm');

        transferObject.notes();
        transferObject.cautionNotes();
    });




});

describe("App.AuthoriseTransfer",function(){
    var authoriseObject;
    beforeEach(function(){
       authoriseObject = App.AuthoriseTransfer.create();
//       var object ={
//           "transferDate": "2013-05-13T12:53:19.065+0800",
//           "transactionId": "ATAID2013051300002601I0211002749",
//           "transactionType": "15",
//           "transactionStatus": "TY",
//           "fromAccountNumber": "5149342080196550",
//           "fromAccountCurrencyCode": "IDR",
//           "payeeId": 0,
//           "amount": 1.00,
//           "currencyCode": "IDR",
//           "toAccountCurrencyCode": "IDR",
//           "toAccountNumber": "02105081619",
//           "etacReqId": "20130513000026",
//           "etacMobileNo": "985667687"
//       };
    });

    it("transactionType",function(){
        authoriseObject.set('transactionType',"15");
        expect(authoriseObject.get('transactionType')).toBe('15');
    });

    it("transferDataForOTPResend",function(){
        authoriseObject.transferDataForOTPResend();
    });

    it("displayableObjectForEtac",function(){
        authoriseObject.displayableObjectForEtac();
    });
    it("transferData",function(){
       authoriseObject.set('transaction',{transactionId:'ATAID2013051600001601I0211002749'});
       authoriseObject.transferData();
    });

    it("displayableObject--moduleName is confirm",function(){
        var expectedResult = [{"key":"eTAC Reference Number","value":null},{"key":"Mobile Number for eTAC","value":null}];
        authoriseObject.set('moduleName','confirm');
        expect(authoriseObject.get('moduleName')).toBe('confirm');
        authoriseObject.displayableObjectForEtac();
        expect(JSON.stringify(authoriseObject.get('displayableObject'))).toEqual(JSON.stringify(expectedResult));
    });

    it("displayableObject--moduleName is not confirm",function(){
        var expectedResult = [{"key":"eTAC Reference Number","value":null},{"key":"Mobile Number for eTAC","value":null}];
        authoriseObject.set('moduleName','preConfirm');
        expect(authoriseObject.get('moduleName')).toBe('preConfirm');
        authoriseObject.set('transferResult',{"etacReqId": "20130513000026",
                                               "etacMobileNo": "985667687"});
        expect(JSON.stringify(authoriseObject.get('displayableObject'))).toEqual(JSON.stringify([]));
    });


});

describe("App.ThirdPartyTransfer",function(){
    var thirdPartyTransferObject;
    var responseObject;
    beforeEach(function(){
        thirdPartyTransferObject = App.ThirdPartyTransfer.create();
        responseObject = {
           "thirdPartyFundTransferResponse": {
               "isOTPRequired": true,
               "fundTransfer": {
                   "channel": "IBKBMW",
                   "currencyCode": "IDR",
                   "remark": "tpt",
                   "etacReqId": "20130518000000",
                   "etacMobileNo": "9842495425",
                   "amount": 22.00,
                   "debitAmount": 22.00,
                   "transferDate": "2013-05-18T12:14:26.760+0800",
                   "exchangeRate": 1.000000000,
                   "recurring": {
                       "frequency": "",
                       "isRecurring": false
                   },
                   "fromAccount": {
                       "accountNumber": "30607824120",
                       "currencyCode": "IDR",
                       "productCategory": "CASA"
                   },
                   "payee": {
                       "payeeId": 175112225235229734,
                       "accountCurrency": "IDR",
                       "accountNumber": "30606453501"
                   }
               }
           }
       };

    });

    it("accountCurrency",function(){
        var accountCurrency = 'accountCurrency';

        var thirdPartyObject = App.ThirdPartyTransfer.create({
           'payee':{
               "accountCurrency":accountCurrency
           }
        });

        expect(thirdPartyObject.get('accountCurrency')).toBe(accountCurrency);
    });

    it("transferDataForAccept",function(){
       var expectedObject ={
           "payee": {
               "payeeId": 175112225235229734,
               "accountCurrency": "IDR",
               "accountNumber": "30606453501"
           },
           "fromAccount": {
               "accountNumber": "30607824120",
               "currencyCode": "IDR",
               "productCategory": "CASA"
           },
           "currencyCode": "IDR",
           "amount": 22.00,
           "transferDate":"Thursday, 30 August 0006",
           "remark": "tpt",
           "channel": "IBKBMW",
           "recurring":{
               "isRecurring":false,
               "startDate":null,
               "endDate":null,
               "frequency":""
           }
       };
        thirdPartyTransferObject.set('payee',Ember.Object.create({
            getPayeeVO: function() {
                return {
                    "payeeId": 175112225235229734,
                    "accountCurrency": "IDR",
                    "accountNumber": "30606453501"
                };
            },
            isIBFTPayee : function() {
                return false;
            }
        }));
        thirdPartyTransferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return {
                    "accountNumber": "30607824120",
                    "currencyCode": "IDR",
                    "productCategory": "CASA"

                };
            }
        }));

        thirdPartyTransferObject.set('currencyCode', expectedObject.currencyCode);
        thirdPartyTransferObject.set('amount', expectedObject.amount);
        thirdPartyTransferObject.set('transferDate',expectedObject.transferDate);
        thirdPartyTransferObject.set('remark', expectedObject.remark);
        thirdPartyTransferObject.set('channel',expectedObject.channel);

        expect(JSON.stringify(thirdPartyTransferObject.transferDataForAccept())).toBe(JSON.stringify(expectedObject));

    });

    it("transferDataForGenerateEtac",function(){
        var expectedObject ={
            "payee": {
                "payeeId": 175112225235229734,
                "accountCurrency": "IDR",
                "accountNumber": "30606453501"
            },
            "fromAccount": {
                "accountNumber": "30607824120",
                "currencyCode": "IDR",
                "productCategory": "CASA"
            },
            "currencyCode": "IDR",
            "amount": 22.00,
            "transferDate":"Thursday, 30 August 0006",
            "remark": "tpt",
            "channel": "IBKBMW",
            "recurring":{
                "isRecurring":false,
                "startDate":null,
                "endDate":null,
                "frequency":""
            }
        };
        thirdPartyTransferObject.set('payee',Ember.Object.create({
            getPayeeVO: function() {
                return {
                    "payeeId": 175112225235229734,
                    "accountCurrency": "IDR",
                    "accountNumber": "30606453501"
                };
            },
            isIBFTPayee : function() {
                return false;
            }
        }));
        thirdPartyTransferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return {
                    "accountNumber": "30607824120",
                    "currencyCode": "IDR",
                    "productCategory": "CASA"

                };
            }
        }));

        thirdPartyTransferObject.set('currencyCode', expectedObject.currencyCode);
        thirdPartyTransferObject.set('amount', expectedObject.amount);
        thirdPartyTransferObject.set('transferDate',expectedObject.transferDate);
        thirdPartyTransferObject.set('remark', expectedObject.remark);
        thirdPartyTransferObject.set('channel',expectedObject.channel);


        expect(JSON.stringify(thirdPartyTransferObject.transferDataForGenerateEtac())).toBe(JSON.stringify(expectedObject));

    });

    describe("displayableToObject", function() {
        it("3rd party",function(){
            thirdPartyTransferObject.set('payee',Ember.Object.create({
                getPayeeVO: function() {
                    return {
                        "payeeId": 175112225235229734
                    };
                },
                isIBFTPayee: function() {
                    return false;
                }
            }));
            thirdPartyTransferObject.payee.set('name',"AccountName");
            thirdPartyTransferObject.payee.set('number',"30606453501");
            var toAccountNameAndNumber = thirdPartyTransferObject.payee.get('name')+", "+thirdPartyTransferObject.payee.get('number');

            thirdPartyTransferObject.set('showCurrencyCode',true);
            expect(thirdPartyTransferObject.get('showCurrencyCode')).toBe(true);
            thirdPartyTransferObject.payee.set('accountCurrency','IDR');
            toAccountNameAndNumber = toAccountNameAndNumber+", "+thirdPartyTransferObject.payee.get('accountCurrency');

            expect(JSON.stringify(thirdPartyTransferObject.displayableToObject())).toBe(JSON.stringify([{
                key: App.i18n.getTranslations().get('move.to'),
                value: toAccountNameAndNumber
            }]));
        });
        it("IBFT",function(){
            thirdPartyTransferObject.set('payee',Ember.Object.create({
                getPayeeVO: function() {
                    return {
                        "payeeId": 175112225235229734
                    };
                },
                isIBFTPayee: function() {
                    return true;
                },
                branch: {
                    bankName: 'BANK DANAMON INDONESIA SYARIAH'
                }
            }));
            thirdPartyTransferObject.payee.set('name',"AccountName");
            thirdPartyTransferObject.payee.set('number',"30606453501");
            var toAccountNameAndNumber = thirdPartyTransferObject.payee.get('name')+", "+thirdPartyTransferObject.payee.get('number');

            thirdPartyTransferObject.set('showCurrencyCode',true);
            expect(thirdPartyTransferObject.get('showCurrencyCode')).toBe(true);
            thirdPartyTransferObject.payee.set('accountCurrency','IDR');
            toAccountNameAndNumber = toAccountNameAndNumber+", "+thirdPartyTransferObject.payee.get('accountCurrency')+', '+thirdPartyTransferObject.payee.branch.bankName;

            expect(JSON.stringify(thirdPartyTransferObject.displayableToObject())).toBe(JSON.stringify([{
                key: App.i18n.getTranslations().get('move.to'),
                value: toAccountNameAndNumber
            }]));
        });
    });

    it("transferCurrencies--for same from and payee currencyCode",function(){
        var expectedObject = {
            "payee":{
                "payeeId": 175112225235229734
            },
            "fromAccount":{
                "accountNumber": "25728357148",
                "currencyCode": "IDR",
                "productCategory": "CASA"
            }
        };

        thirdPartyTransferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return expectedObject.fromAccount;
            }
        }));
        thirdPartyTransferObject.set('payee', Ember.Object.create({
            getPayeeVO: function() {
                return {
                    "payeeId":175112225235229734
                };
            }
        }));

        thirdPartyTransferObject.fromAccount.set('currencyCode','IDR');
        thirdPartyTransferObject.payee.set('currencyCode','IDR');
        var fromCurrency = thirdPartyTransferObject.fromAccount.get('currencyCode');
        var toCurrency = thirdPartyTransferObject.payee.get('currencyCode');
        expect(JSON.stringify(thirdPartyTransferObject.transferCurrencies())).toBe(JSON.stringify([{"code":fromCurrency,"value":fromCurrency}]));
    });

    it("transferCurrencies--for diff from and payee currencyCode",function(){
        var expectedObject = {
            "payee":{
                "payeeId": 175112225235229734
            },
            "fromAccount":{
                "accountNumber": "25728357148",
                "currencyCode": "IDR",
                "productCategory": "CASA"
            }
        };

        thirdPartyTransferObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return expectedObject.fromAccount;
            }
        }));
        thirdPartyTransferObject.set('payee', Ember.Object.create({
            getPayeeVO: function() {
                return {
                    "payeeId":175112225235229734
                };
            }
        }));

        thirdPartyTransferObject.fromAccount.set('currencyCode','IDR');
        thirdPartyTransferObject.payee.set('currencyCode','USD');
        var fromCurrency = thirdPartyTransferObject.fromAccount.get('currencyCode');
        var toCurrency = thirdPartyTransferObject.payee.get('currencyCode');
        expect(JSON.stringify(thirdPartyTransferObject.transferCurrencies())).toBe(JSON.stringify([{"code":fromCurrency,"value":fromCurrency},{"code":toCurrency,"value":toCurrency}]));
    });

    it("displayableObject--moduleName is confirm",function(){
        var expectedResult = [{"key":"eTAC Reference Number","value":null},{"key":"Mobile Number for eTAC","value":null},{"key":"Notes","value":"I still haven't received my eTAC via SMS. What should I do? \n\nSince eTACs are delivered to you via SMS, it is possible that you may experience some delay in receiving you eTAC due to congestion at your mobile operators network. Once you receive your eTAC, you may return to Breeze and click on the Authorise Transactions link on the left menu. You may then select the transaction by matching the transaction reference number received in the SMS, verify the transaction details and then proceed to enter the eTAC to complete the authorization of the transaction. If you haven't received your eTAC within an hour of performing your transaction, please call our Customer Contact Centre at +62-21-57999988 and 68000 from mobile and we shall help you authorize your transaction.","isNote":true}];
        thirdPartyTransferObject.set('moduleName','confirm');
        expect(thirdPartyTransferObject.get('moduleName')).toBe('confirm');
        thirdPartyTransferObject.displayableObjectForEtac();
        thirdPartyTransferObject.notes();
        expect(JSON.stringify(thirdPartyTransferObject.get('displayableObject'))).toEqual(JSON.stringify(expectedResult));
    });

});


describe("App.CreditCardPayment",function(){
    var creditCardPaymentObject;
    beforeEach(function(){
       creditCardPaymentObject = App.CreditCardPayment.create();
    });

    it("transferDataForAccept",function(){
        var expectedObject ={
            "card":{
                "accountNumber":"5149342010001003",
                "currencyCode":"IDR",
                "productCode":"201",
                "productCategory":"CARD"
            },
            "fromAccount": {
                "accountNumber": "30607824120",
                "currencyCode": "IDR",
                "productCategory": "CASA"
            },
            "currencyCode": "IDR",
            "amount": 22.00,
            "transferDate":"Thursday, 30 August 0006",
            "remark": "tpt",
            "channel": "IBKBMW",
            "recurring":{
                "isRecurring":false,
                "startDate":null,
                "endDate":null,
                "frequency":""
            }
        };
        creditCardPaymentObject.set('toAccount',Ember.Object.create({
            getTransferProductVO:function(){
                return {
                    "accountNumber":"5149342010001003",
                    "currencyCode":"IDR",
                    "productCode":"201",
                    "productCategory":"CARD"
                };
            }
        }));
        creditCardPaymentObject.set('fromAccount', Ember.Object.create({
            getTransferProductVO: function() {
                return {
                    "accountNumber": "30607824120",
                    "currencyCode": "IDR",
                    "productCategory": "CASA"

                };
            }
        }));

        creditCardPaymentObject.set('currencyCode', expectedObject.currencyCode);
        creditCardPaymentObject.set('amount', expectedObject.amount);
        creditCardPaymentObject.set('transferDate',expectedObject.transferDate);
        creditCardPaymentObject.set('remark', expectedObject.remark);
        creditCardPaymentObject.set('channel',expectedObject.channel);

        expect(JSON.stringify(creditCardPaymentObject.transferDataForAccept())).toBe(JSON.stringify(expectedObject));

    });

});


